package ch10;

import java.util.Deque;
import java.util.LinkedList;

public class LinkedListClass {

	public static void main(String[] args) {
		//LinkerList类实现了种数据结构
		//实现了（双端）链表结构，队
		//队列结构
		//队列结构具有先进先出，后进后出
		//LinkedList<Computer> linkedList = new LinkedList<Computer>();
		//双端队列
		Deque<Computer> linkedList = new LinkedList<Computer>();
		linkedList.addLast(new Computer("HP1",5000));
		linkedList.addLast(new Computer("HP2",5000));
		linkedList.addLast(new Computer("HP3",5000));
		linkedList.addLast(new Computer("HP4",5000));
		linkedList.addLast(new Computer("HP5",5000));
		linkedList.addLast(new Computer("HP6",5000));
		linkedList.addLast(new Computer("HP7",5000));
		linkedList.addLast(new Computer("HP8",5000));
		
		Computer computer = null;
		while ((computer = linkedList.pollFirst())!=null) {
			System.out.println(computer);
		}
		
		System.out.println("===========================================================");
		
		//双端队列
		linkedList.addFirst(new Computer("HP1",5000));
		linkedList.addFirst(new Computer("HP2",5000));
		linkedList.addFirst(new Computer("HP3",5000));
		linkedList.addFirst(new Computer("HP4",5000));
		linkedList.addFirst(new Computer("HP5",5000));
		linkedList.addFirst(new Computer("HP6",5000));
		linkedList.addFirst(new Computer("HP7",5000));
		linkedList.addFirst(new Computer("HP8",5000));

		while ((computer = linkedList.pollLast())!=null) {
			System.out.println(computer);
		}
	}

}
